package com.aier.school.entity.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.aier.common.common.SystemDateFormatUtil;
import com.aier.school.entity.UserIcardRecord;

public class UserIcardRecordRowMapper implements RowMapper<UserIcardRecord> {

    @SuppressWarnings("unused")
    private int type;
    
    public static final int AND_CARDNUM=1;

    public UserIcardRecordRowMapper() {
    }

    public UserIcardRecordRowMapper(int type) {
        this.type = type;
    }

    @Override
    public UserIcardRecord mapRow(ResultSet rs, int rowNum) throws SQLException {
        
        UserIcardRecord uii = new UserIcardRecord();
        uii.setName(rs.getString("name"));
        if (rs.getTimestamp("am_in") != null) {
            uii.setAm_in(SystemDateFormatUtil.formatDate(rs.getTimestamp("am_in"), SystemDateFormatUtil.FORMAT_TIME_NOTSECOND));
        } else {
            uii.setAm_in("未打卡");
        }
        if (rs.getTimestamp("am_out") != null) {
            uii.setAm_out(SystemDateFormatUtil.formatDate(rs.getTimestamp("am_out"), SystemDateFormatUtil.FORMAT_TIME_NOTSECOND));
        } else {
            uii.setAm_out("未打卡");
        }
        if (rs.getTimestamp("pm_in") != null) {
            uii.setPm_in(SystemDateFormatUtil.formatDate(rs.getTimestamp("pm_in"), SystemDateFormatUtil.FORMAT_TIME_NOTSECOND));
        } else {
            uii.setPm_in("未打卡");
        }
        if (rs.getTimestamp("pm_out") != null) {
            uii.setPm_out(SystemDateFormatUtil.formatDate(rs.getTimestamp("pm_out"), SystemDateFormatUtil.FORMAT_TIME_NOTSECOND));
        } else {
            uii.setPm_out("未打卡");
        }
        
//        switch (type) {
//            case AND_CARDNUM:
//                uii.setCardnum(rs.getString("cardnum"));
//                uii.setName_student(rs.getString("name_student"));
//                break;
//        }
        return uii;
    }


}
